package com.example.demo.exception;

public enum APICommonCode {

    /**
     * NONE
     */
    NONE("-100", "lang.ark.api.none"),

    /**
     * 调用成功
     */
    SUCCESS("0", "lang.ark.common.ok"),

    /**
     * 保存成功
     */
    SAVE_SUCCESS("0", "lang.ark.fed.savedSuccessfully"),

    /**
     * 未知原因和异常导致的失败
     */
    FAIL("100", "lang.ark.interface.resentFail"),
    ;

    private String code;
    private String msg;

    APICommonCode(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public static APICommonCode ofType(String code) {
        for (APICommonCode commonCode : APICommonCode.values()) {
            if (commonCode.getCode() == code) {
                return commonCode;
            }
        }
        return NONE;
    }
}
